<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="">
        姓名：<input type="text" name="name">
        性别：<input type="text" name="ptGender">
        年龄：<input type="text" name="age">
        送检科室：<input type="text" name="sendDepartment">
        床位号：<input type="text" name="badNo">
        大体所见：<input type="text" name="grossDescript">
        镜下所见：<input type="text" name="image">
        病理诊断：<input type="text" name="description">
        <button type="button">提交</button>
    </form>

    <script>
        var btn = document.querySelector('button')
        btn.onclick = function () {
            var xhr = new XMLHttpRequest()
            var name = document.querySelector('[name=name]').value
            var ptGender = document.querySelector('[name=ptGender]').value
            var age = document.querySelector('[name=age]').value
            var sendDepartment = document.querySelector('[name=sendDepartment]').value
            var badNo = document.querySelector('[name=badNo]').value
            var grossDescript = document.querySelector('[name=grossDescript]').value
            var image = document.querySelector('[name=image]').value
            var description = document.querySelector('[name=description]').value
            xhr.open('GET', 'http://localhost:8000/login?name=' + name + '&ptGender=' + ptGender + '&age=' + age + '&sendDepartment=' + sendDepartment + '&badNo=' + badNo + '&grossDescript=' + grossDescript + '&image=' + image + '&description=' + description)
            xhr.send()
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4 && xhr.status === 200) {
                    console.log('登陆成功');
                }
            }
        }
    </script>
</body>
</html>